package com.gitee.openviducn.inspector.auth;

import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * 测试用，模拟ADMIN角色
 * 参考[https://github.com/alibaba/Sentinel/]控制台项目
 */
@Component
public class FakeAuthServiceImpl implements AuthService<HttpServletRequest> {

    @Override
    public AuthUser getAuthUser(HttpServletRequest request) {
        return new AuthUserImpl();
    }

    static final class AuthUserImpl implements AuthUser {

        @Override
        public boolean authTarget(String target, SystemRole[] systemRoles) {
            return true;
        }

        @Override
        public Long getId() {
            return 999L;
        }

        @Override
        public String getUsername() {
            return "FAKE_USERNAME";
        }

        @Override
        public SystemRole getRole() {
            return SystemRole.ADMIN;
        }
    }
}
